package org.minuframework.utils;

import org.minuframework.lang.StringUtils;

public class LangUtils{
    
    public static byte parseByte(String param){
        if (StringUtils.isEmpty(param)) { return 0; }
        return Byte.parseByte(param);
    }
    
    public static byte parseByte(Object object){
        if (object == null) { return 0; }
        return Byte.parseByte(object.toString());
    }
    
    public static short parseShort(String param){
        if (StringUtils.isEmpty(param)) { return 0; }
        return Short.parseShort(param);
    }
    
    public static short parseShort(Object object){
        if (object == null) { return 0; }
        return Short.parseShort(object.toString());
    }
    
    public static int parseInt(String param){
        if (StringUtils.isEmpty(param)) { return 0; }
        return Integer.parseInt(param);
    }
    
    public static int parseInt(Object object){
        if (object == null) { return 0; }
        return Integer.parseInt(object.toString());
    }
    
    public static long parseLong(String param){
        if (StringUtils.isEmpty(param)) { return 0; }
        return Long.parseLong(param);
    }
    
    public static long parseLong(Object object){
        if (object == null) { return 0; }
        return Long.parseLong(object.toString());
    }
    
    public static float parseFloat(String param){
        if (StringUtils.isEmpty(param)) { return 0; }
        return Float.parseFloat(param);
    }
    
    public static float parseFloat(Object object){
        if (object == null) { return 0; }
        return Float.parseFloat(object.toString());
    }
    
    public static double parseDouble(String param){
        if (StringUtils.isEmpty(param)) { return 0.00; }
        return Double.parseDouble(param);
    }
    
    public static double parseDouble(Object object){
        if (object == null) { return 0.00; }
        return Double.parseDouble(object.toString());
    }
    
    public static boolean parseBoolean(String param){
        if (StringUtils.isEmpty(param)) { return false; }
        return Boolean.parseBoolean(param);
    }
    
    public static boolean parseBoolean(Object object){
        if (object == null) { return false; }
        return Boolean.parseBoolean(object.toString());
    }
    
}
